
datablock AudioProfile(DB605IdleSound)
{
   filename    = "./DB605idle.wav";
   description = AudioDefaultLooping3d;
   preload = true;
};
datablock AudioProfile(DB605FlySound)
{
   filename    = "./DB605flyloop.wav";
   description = AudioDefaultLooping3d;
   preload = true;
};
datablock AudioProfile(DB605EngineOnSound)
{
   filename    = "./DB605engineon2.wav";
   description = AudioDefault3d;
   preload = true;
};
datablock AudioProfile(DB605EngineOffSound)
{
   filename    = "./DB605engineoff.wav";
   description = AudioDefault3d;
   preload = true;
};

datablock AudioProfile(DiveBomberScreamSound) {
	filename = "./sound/DiveBomberScream.wav";
	description = AudioDefaultLooping3d;
	preload = true;
};
datablock AudioProfile(DiveBomberScreamStartSound) {
	filename = "./sound/DiveBomberScreamStart.wav";
	description = AudioDefault3d;
	preload = true;
};
datablock AudioProfile(DiveBomberPullSound) {
	filename = "./sound/DiveBomberPull.wav";
	description = AudioDefault3d;
	preload = true;
};
datablock AudioProfile(CorsairRattleSound) {
	filename = "./sound/AirframeRattle1.wav";
	description = AudioDefault3d;
	preload = true;
};


datablock ProjectileData(CorsairExplosionProjectile : tankshellProjectile)
{
   explosion           = tankShellExplosion;

   directDamageType  = $DamageType::VehicleExplosion;
   radiusDamageType  = $DamageType::VehicleExplosion;

   explodeOnDeath		= 1;

   armingDelay         = 0;
   lifetime            = 0;

   uiName = "";
};



datablock ParticleData(CorsairDamageParticleA)
{
   dragCoefficient      = 1;
   windCoefficient     = 3;
   gravityCoefficient   = -0.7;
   inheritedVelFactor   = -0.5;
   constantAcceleration = 0.0;
   spinRandomMin = -90;
   spinRandomMax = 90;
   lifetimeMS           = 1500;
   lifetimeVarianceMS   = 300;
   textureName          = "base/data/particles/cloud";
   colors[0]     = "0.1 0.1 0.1 0.2";
   colors[1]     = "0 0 0 0.1";
   colors[2]     = "0 0 0 0";

   sizes[0]      = 1.5;
   sizes[1]      = 3;
   sizes[2]	 = 5;
	times[0]	= 0.0;
	times[1]	= 0.1;
	times[2]	= 1;

useInvAlpha = true;
};

datablock ParticleEmitterData(CorsairDamageEmitterA)
{
   ejectionPeriodMS = 12;
   periodVarianceMS = 2;
   ejectionVelocity = -5;
   velocityVariance = 1.5;
   ejectionOffset   = 0.5;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = CorsairDamageParticleA;   
   
};



datablock ParticleData(CorsairDamageParticleC)
{
   dragCoefficient      = 1;
   windCoefficient     = 3;
   gravityCoefficient   = -0.7;
   inheritedVelFactor   = -0.5;
   constantAcceleration = 0.0;
   spinRandomMin = -90;
   spinRandomMax = 90;
   lifetimeMS           = 1500;
   lifetimeVarianceMS   = 300;
   textureName          = "base/data/particles/cloud";
   colors[0]     = "0.1 0.1 0.1 0.8";
   colors[1]     = "0 0 0 0.4";
   colors[2]     = "0 0 0 0";

   sizes[0]      = 1.5;
   sizes[1]      = 3;
   sizes[2]	 = 5;
	times[0]	= 0.0;
	times[1]	= 0.1;
	times[2]	= 1;

useInvAlpha = true;
};

datablock ParticleEmitterData(CorsairDamageEmitterC)
{
   ejectionPeriodMS = 12;
   periodVarianceMS = 2;
   ejectionVelocity = -5;
   velocityVariance = 1.5;
   ejectionOffset   = 0.5;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = CorsairDamageParticleC;   
   
};




datablock WheeledVehicleData(CorsairVehicle)
{
	category = "Vehicles";
	displayName = " ";
	shapeFile = "./Corsair1.dts"; //"~/data/shapes/skivehicle.dts"; //
	emap = true;
	minMountDist = 3;

	handsOnVehicleEDITED = 1;
   
   numMountPoints = 1;
   mountThread[0] = "sit";

	maxDamage = 200.00;
	destroyedLevel = 200.00;
	energyPerDamagePoint = 160;
	speedDamageScale = 1.04;
	collDamageThresholdVel = 20.0;
	collDamageMultiplier   = 0.02;

	massCenter = "0 1 -2";
   //massBox = "2 5 1";

	maxSteeringAngle = 0.9785;  // Maximum steering angle, should match animation
	integration = 4;           // Force integration time: TickSec/Rate
	tireEmitter = VehicleTireEmitter; // All the tires use the same dust emitter

	// 3rd person camera settings
	cameraRoll = false;         // Roll the camera with the vehicle
	cameraMaxDist = 18;         // Far distance from vehicle
	cameraOffset = 5;        // Vertical offset from camera mount point
	cameraLag = 0.5;           // Velocity lag of camera
	cameraDecay = 0.75;        // Decay per sec. rate of velocity lag
	cameraTilt = 0.2;
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.1;

	useEyePoint = false;  //change "false" to "true" to make 1st person view a relative 3rd person view	

	defaultTire	= CorsairTire;
	defaultSpring	= CorsairSpring;
	flatTire	= CorsairFlatTire;
	flatSpring	= CorsairFlatSpring;
    numWheels = 3;
	
	wheelTire[2] = CorsairBackTire;
	wheelSpring[2] = CorsairBackSpring;
	wheelSteering[0] = 0;
	wheelSteering[1] = 0;
	wheelSteering[2] = -1;

	// Rigid Body
	mass = 200; //200
	density = 5.0;
	drag = 0.6;
	bodyFriction = 0.6;
	bodyRestitution = 0.6;
	minImpactSpeed = 10;        // Impacts over this invoke the script callback
	softImpactSpeed = 10;       // Play SoftImpact Sound
	hardImpactSpeed = 15;      // Play HardImpact Sound
	groundImpactMinSpeed    = 10.0;
	// Engine
	engineTorque = 400; //450;       // Engine power
	engineBrake = 400;         // Braking when throttle is 0
	brakeTorque = 900;        // When brakes are applied
	maxWheelSpeed = 35;        // Engine scale by current speed / max speed

	rollForce		= 28000; //35000
	yawForce		= 700; //600
	pitchForce		= 400;
	rotationalDrag		= 0.5;

	// Energy
	maxEnergy = 100;
	jetForce = 3000;
	minJetEnergy = 30;
	jetEnergyDrain = 2;

   isSled = false;

   forwardThrust		= 5300; //5300;//4700
	reverseThrust		= 2700; //2700
	lift			= 100;
	maxForwardVel		= 65;
	maxReverseVel		= 65;
	horizontalSurfaceForce	= 10;   //22 Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning)
	verticalSurfaceForce	= 20;  //27
	rollForce		= 22000; //22000
	yawForce		= 8700;  //12000
	pitchForce		= 10000;  //10000
	rotationalDrag		= 0.6;
	stallSpeed		= 30;

//   forwardThrust		= 2000;
//	reverseThrust		= 2000;
//	lift			= 100;
//	maxForwardVel		= 70;
//	maxReverseVel		= 70;
//	horizontalSurfaceForce	= 100;   // Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning)
//	verticalSurfaceForce	= 100; 
//	rollForce		= 6000;
//	yawForce		= 6000;
//	pitchForce		= 4000;
//	rotationalDrag		= 0.5;
//	stallSpeed		= 10;
//
//   forwardThrust		= 2500;
//	reverseThrust		= 500;
//	lift			= 15000;
//	maxForwardVel		= 60;
//	maxReverseVel		= 10;
//	horizontalSurfaceForce	= 500;   // Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning)
//	verticalSurfaceForce	= 500; 
//	rollForce		= 5000;
//	yawForce		= 5000;
//	pitchForce		= 5000;
//	rotationalDrag		= 0.1;
//	stallSpeed		= 10;

	splash = vehicleSplash;
	splashVelocity = 4.0;
	splashAngle = 67.0;
	splashFreqMod = 300.0;
	splashVelEpsilon = 0.60;
	bubbleEmitTime = 1.4;
	splashEmitter[0] = vehicleFoamDropletsEmitter;
	splashEmitter[1] = vehicleFoamEmitter;
	splashEmitter[2] = vehicleBubbleEmitter;
	mediumSplashSoundVelocity = 10.0;   
	hardSplashSoundVelocity = 20.0;   
	exitSplashSoundVelocity = 5.0;
		
	//mediumSplashSound = "";
	//hardSplashSound = "";
	//exitSplashSound = "";
	
	// Sounds
	//   jetSound = ScoutThrustSound;
	//engineSound = idleSound;
	//squealSound = skidSound;
	softImpactSound = slowImpactSound;
	hardImpactSound = fastImpactSound;
	//wheelImpactSound = slowImpactSound;

	//   explosion = VehicleExplosion;
	justcollided = 0;

   uiName = "Corsair Jabo";
	rideable = true;
		lookUpLimit = 0.55;
		lookDownLimit = 0.5;

	paintable = true;
   
   damageEmitter[0] = CorsairDamageEmitterA;
	damageEmitterOffset[0] = "0.0 2 0.4 ";
	damageLevelTolerance[0] = 0.50;

   damageEmitter[1] = CorsairDamageEmitterC;
	damageEmitterOffset[1] = "0.0 2 0.4 ";
	damageLevelTolerance[1] = 0.75;


   numDmgEmitterAreas = 3;

   //initialExplosionProjectile = VehicleExplosionProjectile;
   initialExplosionOffset = 0;         //offset only uses a z value for now

   burnTime = 0;

   finalExplosionProjectile = VehicleFinalExplosionProjectile;
   finalExplosionOffset = 0.5;          //offset only uses a z value for now


	minExplosionspeed = 14;

   minRunOverSpeed    = 2;   //how fast you need to be going to run someone over (do damage)
   runOverDamageScale = 5;   //when you run over someone, speed * runoverdamagescale = damage amt
   runOverPushScale   = 1.2; //how hard a person you're running over gets pushed

   // Advanced Steering
   steeringAutoReturn = false;
   // steeringAutoReturnRate = 0.9;
   // steeringAutoReturnMaxSpeed = 10;
   steeringUseStrafeSteering = false;
   // steeringStrafeSteeringRate = 0.1;
	
	numGuns = 3;
	gunImage       [0] = CorsairMGLeftImage;
	gunSlot        [0] = 2;
	gunOperatorSlot[0] = 0;
	gunTrigger     [0] = 0;
	gunImage       [1] = CorsairMGRightImage;
	gunSlot        [1] = 3;
	gunOperatorSlot[1] = 0;
	gunTrigger     [1] = 0;
	gunImage       [2] = CorsairBombImage;
	gunSlot        [2] = 1;
	gunOperatorSlot[2] = 0;
	gunTrigger     [2] = 2; // jump
	
	impactExplosionSpeed = 14;
	impactExplosionProjectile = CorsairExplosionProjectile;
	
	slowSpeed = 2;
	fastSpeed = 45;
	veryFastSpeed = 85;
	gLimit = 0.08;
	
	stateDownSound    [Off     ] = DB605EngineOffSound;
	stateUpSound      [Idle    ] = DB605EngineOnSound;
	stateUpSoundTimeMs[Idle    ] = 800;
	stateSound        [Idle    ] = DB605IdleSound;
	stateSound        [Slow    ] = DB605IdleSound;
	stateSound        [Fast    ] = DB605FlySound;
	stateSound        [VeryFast] = DB605FlySound;
	
	stateAnimation        [Off     ] = prop_still;
	stateUpAnimation      [Idle    ] = start_up;
	stateUpAnimationTimeMs[Idle    ] = 800;
	stateAnimation        [Idle    ] = prop_slow;
	stateAnimation        [Slow    ] = prop_slow;
	stateAnimation        [Fast    ] = prop_fast;
	stateAnimation        [VeryFast] = prop_fast;
	
	highGStartSound = CorsairRattleSound;
	
	stateImageSlot = 0;
	stateImage      [Idle    ] = CorsairExhaustImage1;
	stateImage      [Slow    ] = CorsairExhaustImage1;
	stateImage      [Fast    ] = CorsairExhaustImage1;
	stateImage      [VeryFast] = CorsairExhaustImage1;
};


function CorsairVehicle::onSlow(%data, %vehicle, %dir) {
	if(%dir == -1) {
		%vehicle.setWheelTire(0, CorsairTire);
		%vehicle.setWheelTire(1, CorsairTire);
		%vehicle.setWheelTire(2, CorsairBackTire);
	}
}
function CorsairVehicle::onFast(%data, %vehicle, %dir) {
	if(%dir == 1) {
		%vehicle.setWheelTire(0, EmptyTire);
		%vehicle.setWheelTire(1, EmptyTire);
		%vehicle.setWheelTire(2, EmptyTire);
	}
	
	cancel(%vehicle.Corsair_DiveSoundSchedule);
	if(%vehicle.Corsair_Screaming) %vehicle.playAudio(2, DiveBomberPullSound);
	%vehicle.Corsair_Screaming = 0;
}
function CorsairVehicle::onVeryFast(%data, %vehicle, %dir) {
	%vehicle.playAudio(2, DiveBomberScreamStartSound);
	%vehicle.Corsair_DiveSoundSchedule = %vehicle.schedule(2000, playAudio, 2, DiveBomberScreamSound);
	%vehicle.Corsair_Screaming = 1;
}
function CorsairVehicle::onHighG(%data, %vehicle) {
	cancel(%vehicle.Corsair_DiveSoundSchedule);
	if(%vehicle.Corsair_Screaming) %vehicle.playAudio(2, DiveBomberPullSound);
	%vehicle.Corsair_Screaming = 0;
}

package CorsairPackage {
	function CorsairBombImage::onFire(%data, %obj, %slot) {
		if(vectorLen(%obj.getVelocity()) > 10) {
			parent::onFire(%data, %obj, %slot);
			%obj.hideNode(BombA);
			%obj.hideNode(BombB);
			%obj.hideNode(BombC);
		}
	}
	function CorsairBombImage::OnReady(%data, %obj, %slot) {
		%obj.unhideNode(BombA);
		%obj.unhideNode(BombB);
		%obj.unhideNode(BombC);
	}
};
activatePackage(CorsairPackage);
